package com.lgq.cfw.bean.message;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Lin
 * @date 2019-02-05 14:16
 **/
public class Message {
  private int code;
  private String msg;
  private Map<String,Object> content=new HashMap<>();
  private Map<String,Object> ext=new HashMap<>();
  public static Message success(String msg,Map<String,Object> ext){
    Message message=new Message();
    message.setCode(1);
    message.setMsg(msg);
    message.setExt(ext);
    return message;
  }

  public static Message fail(String msg,Map<String,Object> ext){
    Message message=new Message();
    message.setCode(0);
    message.setMsg(msg);
    message.setExt(ext);
    return message;
  }

  public Message add(String key, Object value){
    this.getContent().put(key,value);
    return this;
  }

  public int getCode() {
    return code;
  }

  public void setCode(int code) {
    this.code = code;
  }

  public String getMsg() {
    return msg;
  }

  public void setMsg(String msg) {
    this.msg = msg;
  }

  public Map<String, Object> getContent() {
    return content;
  }

  public void setContent(Map<String, Object> content) {
    this.content = content;
  }

  public Map<String, Object> getExt() {
    return ext;
  }

  public void setExt(Map<String, Object> ext) {
    this.ext = ext;
  }
}
